package com.watson.reflection;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @program: mytest
 * @description: dynamic subject
 * @author: zhangpeng348@jd.com
 * @date: 2018-11-30 11:51
 **/
public class DynamicSubject implements InvocationHandler {

    public Object object;

    public DynamicSubject() {}

    public DynamicSubject(Object object) {
        this.object = object;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("before calling " + method);
        method.invoke(object, args);
        System.out.println("after calling " + method);
        return null;
    }
}
